/**
 * careerOptions.js
 * Copyright (C) 2008-2011 Tommi Rautava
 * 
 * This file is part of Popmungo.
 *
 * Popmungo is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Popmungo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

org.mozdev.popmungo.CareerOptions = {
	onLoad: function careerOptionsOnLoad() {
		try {
			this.showNumberOfSoldTicketsPerShowOnCommand();
			this.highlightLowTicketLimitOnCommand();
		}
		catch (err) {
			org.mozdev.popmungo.logger.debug(err);
		}
	},
	
	showNumberOfSoldTicketsPerShowOnCommand:
	function showNumberOfSoldTicketsPerShowOnCommand() {
		var cb = document.getElementById('career.showNumberOfSoldTicketsPerShow.checkbox');
		var disabled = !cb.checked || cb.disabled;
		
		document.getElementById('career.showSoldTicketsInCompactFormat.checkbox').disabled = disabled;

		return true;
	},

	highlightLowTicketLimitOnCommand:
	function highlightLowTicketLimitOnCommand() {
		var cb = document.getElementById('career.highlightLowTicketLimit.enabled.checkbox');
		var disabled = !cb.checked || cb.disabled;
		
		document.getElementById('career.lowTicketLimit.soldOutInDays.label').disabled = disabled;
		document.getElementById('career.lowTicketLimit.percentage.label').disabled = disabled;
		
		document.getElementById('career.soldOutInDays.warningLevel.textbox.label').disabled = disabled;
		document.getElementById('career.soldOutInDays.warningLevel.textbox').disabled = disabled;
		document.getElementById('career.percentage.warningLevel.textbox').disabled = disabled;

		document.getElementById('career.soldOutInDays.alertLevel.textbox.label').disabled = disabled;
		document.getElementById('career.soldOutInDays.alertLevel.textbox').disabled = disabled;
		document.getElementById('career.percentage.alertLevel.textbox').disabled = disabled;

		return true;
	}
};

org.mozdev.popmungo.logger.log("org.mozdev.popmungo.CareerOptions loaded");

// EOF